package com.qc.ayouth.shop.admin.service.user.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qc.ayouth.shop.admin.service.user.AdminUsersService;
import com.qc.ayouth.shop.core.constants.CommonConst;
import com.qc.ayouth.shop.dbs.entity.TUsers;
import com.qc.ayouth.shop.dbs.service.users.TUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Haojg on 2020/7/6
 */
@Service
public class AdminUsersServiceImpl implements AdminUsersService {
    @Autowired
    TUsersService tUsersService;

    @Override
    public IPage<TUsers> searchUserList(String username, String mobile, Integer pageNo, Integer pageSize) {
        Page<TUsers> pageConfig = new Page<>(pageNo, pageSize);
        QueryWrapper<TUsers> qw = new QueryWrapper<>();
        qw.eq("is_deleted", CommonConst.IS_DELETED_NONE);
        if (!"".equals(username)) {
            qw.like("username", username);
        }
        if (!"".equals(mobile)) {
            qw.likeRight("mobile", mobile);
        }
        return tUsersService.page(pageConfig, qw);
    }
}
